package com.njwb.filter;

import org.springframework.cloud.gateway.filter.GatewayFilter;
import org.springframework.cloud.gateway.filter.factory.AbstractNameValueGatewayFilterFactory;
import org.springframework.stereotype.Component;

@Component
public class PrintFilterPrameterGatewayFilterFactory extends AbstractNameValueGatewayFilterFactory {
    @Override
    public GatewayFilter apply(NameValueConfig config) {
        return ((exchange, chain) -> {
            //读取过滤器工厂配置中的参数名和值
            System.out.println(config.getName() + ":" + config.getValue());
            //请求下发
            return chain.filter(exchange);
        });
    }
}
